<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%-- <%@ include file="/adapter/adapter-easyui.jsp" %> --%>
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
<link href="${pageContext.request.contextPath}/frontframe/easyui/themes/easyui-extend.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">

function save(){
	var str_data=$("#appverinfo input").map(function(){
		   return ($(this).attr("name")+'='+$(this).val());
		 }).get().join("&") ;
    $.ajax({
        url:"${ctx}/version/addVersion",
        type: "POST",      
        dataType:"json",
        data: str_data,
        async: false,
        success: function(data) {
        	if(data.flag>0){
	            alert("保存成功！");	
	            //window.location.reload();
        	}
/* 	          $.each(data, function(index, element) {
             window.location.reload();
          }); */
        },
        error: function() {
          alert("error");
        }
      });
}

function changeValue(Value){
	document.getElementById("appId").value=Value;
	document.getElementById("lastVersionId").value=document.getElementById(Value).value;
}

function changeValue1(Value){
	document.getElementById("isMustUpdate").value=Value;
}

function  goBack(){
	//window.location.href='${ctx}/auth/appDeviceList?appid=${appid}';
	window.history.back(-1);
	//window.history.go(-2);
}
</script>
</head>
<body>
     <div class="panel panel-default">
   <div class="panel-heading">
      <h3 class="panel-title">
          	添加版本
      </h3>
   </div>
   <div class="panel-body">
	<!-- <div id="p" class="easyui-panel" title="交易信息" style="width:100%;height:100%;padding:10px;" > -->
              <form class="form-horizontal" role="form"  id="appverinfo">
                    <c:forEach items="${verList}" var="version">
         				<input id="${version.app_id}" value="${version.APP_VERSION_ID}" disabled="disabled" type="hidden">
         			</c:forEach>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="appId">应用编号</label>
                          <div class="col-xs-4">
                          	 <input class="form-control" id="appId"  name="appId" type="hidden"  value="${verList[0].app_id}" placeholder=""/>
                             <select id="appId2" name="appId2" class="form-control" onclick="changeValue(this.value)">
                             				<c:forEach items="${verList}" var="version">
                             				<option value="${version.app_id}"> ${version.app_name} </option>
                             				</c:forEach>
                           		
                             </select>
                          </div>  
                          <label class="col-xs-2 control-label" for="appVersionId">应用版本号</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="appVersionId" name="appVersionId" type="text"   value="" placeholder=""/>
                          </div>                           
                       </div>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="appVersionDate">版本发布日期</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="appVersionDate" name="appVersionDate" type="text"  placeholder=""/>
                          </div>  
                          <label class="col-xs-2 control-label" for="lastVersionId">上一版本号</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="lastVersionId" name="appLastVersionId" value="${verList[0].app_version_id}" type="text" disabled="disabled"  readonly="readonly"  placeholder=""/>
                          </div>                           
                       </div>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="appUpdateUrl">版本升级地址</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="appUpdateUrl" name="appUpdateUrl" type="text"    value="" placeholder=""/>
                          </div>
                          <label class="col-xs-2 control-label" for="appFileSize">升级包大小</label>
                          <div class="col-xs-4">
                          	 <input class="form-control" id="appFileSize" name="appFileSize" type="text"    value="" placeholder=""/>
                          </div>                          
                       </div>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="appFileHash">升级包jash码</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="appFileHash" name="appFileHash" type="text"    value="" placeholder=""/>
                          </div>
                          <label class="col-xs-2 control-label" for="isMustUpdate">是否必须升级</label>
                          <div class="col-xs-4">
                          	 <input class="form-control" id="isMustUpdate"  name="isMustUpdate" type="hidden"   value="Y" placeholder=""/>
                             <select id="isMustUpdate2" name="isMustUpdate2" class="form-control" onclick="changeValue1(this.value)" >
                           		<option value="Y">是</option>
                           		<option value="N">否</option>
                             </select>
                          </div>                          
                       </div>
                       <div class="form-group  text-center">
                            <button type="button" class="btn btn-default"  onclick="save();">保存</button>
                            <button type="button" class="btn btn-default"   onclick="goBack()">返回</button>
                      </div>
                </form>
	</div>
	</div>

</body>
</html>
